/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package helper;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

/**
 *
 * @author satria.sp
 */
public class helperLDAP {
    Properties properties = new Properties();
     
     public void LDAPhelper(){ 
     }
     public void setProp(String pstrContext,String pstrUrl,String pstrUid,String pstrPwd){ 
        properties.put( Context.INITIAL_CONTEXT_FACTORY,pstrContext);
        properties.put( Context.PROVIDER_URL, pstrUrl);
        properties.put( Context.REFERRAL, "follow" );

        // set properties for authentication
        properties.put( Context.SECURITY_PRINCIPAL, pstrUid);
        properties.put( Context.SECURITY_CREDENTIALS,pstrPwd);
     }
     
     public DirContext  ldapConnect(){
         DirContext  context = null;
         try {
             context = new InitialDirContext(properties);
         } catch (Exception e) {
             
         } 
         return context;
     }
     
     
}
